package utils;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * Application Lifecycle Listener implementation class DefaultValuesSessionListener
 *
 */

public class DefaultValuesHttpSessionListener implements HttpSessionListener {

    /**
     * Default constructor. 
     */
    public DefaultValuesHttpSessionListener() { }

	/**
     * @see HttpSessionListener#sessionCreated(HttpSessionEvent)
     */
    public void sessionCreated(HttpSessionEvent arg0) {

    	HttpSession session = arg0.getSession();
    	if ( session.getAttribute("currentRoomId") == null )
    		//set default room
    		//TODO : check if room exist
    		arg0.getSession().setAttribute("currentRoomId", "1");
    	
    }

	/**
     * @see HttpSessionListener#sessionDestroyed(HttpSessionEvent)
     */
    public void sessionDestroyed(HttpSessionEvent arg0) {
    	
    }
	
}
